<template>
    <div id="credit"></div>
    <div id="cesiumContainer"></div>
</template>
<script lang="ts" setup>
import * as Cesium from 'cesium';
import { ACCESS_TOKEN, FLY_MODEL } from '../../utils/constant';
Cesium.Ion.defaultAccessToken = ACCESS_TOKEN;
/**
 * Viewer查看器
 */
const initMap = () => {
    const viewer = new Cesium.Viewer('cesiumContainer', {
        // 是否显示信息窗口
        infoBox: false,
        // 是否显示查询框
        geocoder: false,
        // 是否显示home按钮
        homeButton: false,
        // 切换3D和2D的按钮
        sceneModePicker: false,
        // 切换图层按钮
        baseLayerPicker: false,
        // 更多帮助按钮
        navigationHelpButton: false,
        // 动画表盘
        animation: false,
        creditContainer: 'credit',
        timeline: false,
        fullscreenButton: false,
        vrButton: false
    });
    // 设置显示fps
    viewer.scene.debugShowFramesPerSecond = false;
    var position2 = Cesium.Cartesian3.fromDegrees(113.3191, 23.109, 2000);

    // flyto,让相机飞往某个地方
    viewer.camera.flyTo({
        destination: position2,
        orientation: {
            heading: Cesium.Math.toRadians(0),
            pitch: Cesium.Math.toRadians(-90),
            roll: 0
        }
    });

    viewer.entities.add({
        name: 'Airplane',
        position: Cesium.Cartesian3.fromDegrees(113.3191, 23.109, 1500),
        model: {
            uri: FLY_MODEL,
            // 设置飞机的最小像素
            minimumPixelSize: 128,
            // 设置飞机的轮廓
            silhouetteSize: 5,
            // 设置轮廓的颜色
            silhouetteColor: Cesium.Color.WHITE,
            // 设置相机距离模型多远的距离显示
            distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 200000)
        }
    });
};
onMounted(() => {
    initMap();
});
</script>
<style lang="scss" scoped></style>
